(function (global, document, undefined) {
    var targetFileName = "fruit.js";
    var jquery = "../3rdParty/jquery/jquery-1.9.1.js";
    var underscore = "../3rdParty/underscore/underscore.js";
    var filePathObj = {
        "core":{
            "oop":{
                dependencies:[],
                path:[
                    underscore,
                    "core/namespace.js",
                    "core/util.js",
                    "core/cache.js",
                    "core/log.js",
                    "core/oop.js",
                    "core/Converter.js",
                    "core/Formatter.js",
                    "core/Binding.js",
                    "core/Collection.js",
                    "core/ObservableObject.js",
                    "core/ObservableCollection.js",
                    "core/ModelFactory.js"
                ]
            },
            "dom":{
                path:[
                    "core/support.js",
                    "core/env.js",
                    "dom/dom.js",
                    "dom/fx.js",
                    "dom/position.js"
                ]
            },
            "event":{
                dependencies:["core.oop"],
                path:[
                    "core/support.js",
                    "core/cache.js",
                    "event/event.js",
                    "event/event-fix.js"
                ]
            },
            "ajax":{
                dependencies:["core.oop"],
                path:[
                    "data/http.js"
                ]
            },
            "WebSocket":{
                dependencies:["core.oop"],
                path:[
                    "data/WebSocket.js"
                ]
            }


        },
        "ui":{
            "Element":{
                dependencies:["core"],
                path:[
                    "ui/Element.js",
                    "ui/CollectionView.js",
                    "ui/viewEngine.js",
                    "ui/Component.js"
                ]
            },
            "base":{
                dependencies:["ui.Element"],
                path:["ui/Popup.js"]
            },
            "button":{
                dependencies:["ui.Element"],
                path:["ui/Button.js"]
            },
            "checkbox":{
                dependencies:["ui.Element"],
                path:["ui/CheckBox.js"]
            },
            "tooltip":{
                dependencies:["ui.Element"],
                path:["ui/Tooltip.js"]
            },
            "tooltipdialog":{
                dependencies:["ui.Element"],
                path:["ui/TooltipDialog.js"]
            },
            "SelectableList":{
                dependencies:["ui.Element"],
                path:["ui/SelectableList.js"]
            },
            "DropdownButton":{
                dependencies:["ui.Element"],
                path:["ui/DropdownButton.js"]
            },
            "Combobox":{
                dependencies:["ui.base", "ui.SelectableList"],
                path:["ui/ComboBox.js"]
            },
            "TextBox":{
                dependencies:["ui.base"],
                path:["ui/TextBox.js"]
            },
            "Radio":{
                dependencies:["ui.base"],
                path:["ui/Radio.js"]
            },
            "Dialog":{
                dependencies:["ui.base"],
                path:["ui/Dialog.js"]
            },
            "DataTable":{
                dependencies:["ui.base"],
                path:["ui/DataTable.js"]
            },
            "Tab":{
                dependencies:["ui.base"],
                path:["ui/Tab.js"]
            },
            "Tree":{
                dependencies:["ui.base"],
                path:["ui/Tree.js"]
            },
            "HTMLLoader":{
                dependencies:["ui.base"],
                path:["ui/HTMLLoader.js"]
            },
            "HTMLParser":{
                dependencies:["ui.base"],
                path:["ui/HTMLParser.js"]
            },
            "CodeViewer":{
                dependencies:["ui.base"],
                path:["ui/CodeViewer.js"]
            }


        },
        "util":{
            "util":{
                path:[
                    "util/color.js",
                    "util/Animation.js"
                ]
            }
        },
        /*"graphic":{
            "core":{
                dependencies:['core', 'util'],
                path:[
                    "data/Graph.js",
                    "graphic/Core.js",
                    "graphic/TopologyICON.js",
                    "graphic/Topology3D.js",
                    "graphic/TopologyNode.js",
                    "graphic/TopologyLink.js",
                    "graphic/TopologyGroup.js",
                    "graphic/Topology.js",
                    //"graphic/GeneralTopology.js",
                    "graphic/Topology/Topology.NodeToolTip.js",
                    "graphic/Topology/Topology.LinkToolTip.js",
                    "graphic/Topology/Topology.Sidebar.js",
                    "graphic/Topology/Topology.Scene.js",
                    "graphic/Topology/Topology.SceneDefault.js",
                    "graphic/Manometer.js",
                    "graphic/Pie.js"
                ]
            }
        },*/
        "app":{
            "core":{
                dependencies:['core', 'util'],
                path:[
                    "core/app.js"
                ]
            }
        }

    };
    var ln,scriptSrc,match ;
    var path = "";
    var scripts = document.getElementsByTagName('script');
    var host = window.location.hostname;
    for (i = 0, ln = scripts.length; i < ln; i++) {
        scriptSrc = scripts[i].src;
        match = scriptSrc.match(targetFileName);
        if (match) {
            path = scriptSrc.substring(0, scriptSrc.length - match[0].length);
            break;
        }
    }
    document.write('<script type="text/javascript" src="' + path + jquery + '"></script>');
//var antpath = [];
//tpath.push('<path path="${lib}/json2.js"/>');
    for (var i in filePathObj) {
        var package = filePathObj[i];
        for (var j in package) {
            var files = package[j].path;
            if (files) {
                for (var h = 0; h < files.length; h++) {
                    //console.log(files[h]);
                    document.write('<script type="text/javascript" src="' + path + files[h] + '"></script>');
                    //antpath.push('<path path="${js}/'+files[h]+'"/>');
                }
            }
        }
    }
//console.dir(antpath.join("\r"));
}(window, document, undefined));

